<script src="https://cdn.bootcss.com/js-cookie/latest/js.cookie.js"></script>
<script src="https://cdn.bootcss.com/intro.js/2.9.3/intro.min.js"></script>
<link href="https://cdn.bootcss.com/intro.js/2.9.3/introjs.min.css" rel="stylesheet">
<script type="text/javascript">
    var offset=window.innerWidth>1200?0:1;
    var author = {
        steps: [
            {
                element: '#create-chapter',
                intro: "续写您的作品", position: 'bottom'
            },
            {
                element: document.querySelectorAll('.update-chapter')[offset],
                intro: "更新已存在的章节", position: 'right'
            },
            {
                element: document.querySelectorAll('.switch-chapter')[offset],
                intro: "新写的章节不好？切换回之前的版本",
                position: 'right'
            },
            {
                element: '#repository-setting',
                intro: '在这里可以设置您的作品标题或介绍等',
                position: 'bottom'
            },
            {
                element: '#show-fork',
                intro: "在这里可以查看哪些人续写了您的作品",
                position: 'bottom'
            },
            {
                element: '#pull-request',
                intro: '在这里可以查看哪些人向您推荐自己的续写章节'
            }
        ]
    };
    var visitor = {
        steps: [
            {
                element: document.querySelector('.intro-repository-like'),
                intro: "您可以给作品点赞"
            },
            {
                element: document.querySelectorAll('.intro-like')[offset],
                intro: "您可以给章节点赞",
                position: 'right'
            },
            {
                element: '#intro-issue',
                intro: "您可以在这里讨论作品",
                position: 'bottom'
            },
            {
                element: document.querySelectorAll('.intro-comment')[offset],
                intro: "您可以给章节评论",
                position: 'right'
            },
            {
                element: '#create-fork',
                intro: '如果作者允许创建副本，您可以完全复制当前所有章节成为新的副本，并在此基础上续写他人作品。副本的更新不会影响原先的作品。',
                position: 'bottom'
            }
        ]
    };

    function startIntro(options, type) {
        var intro = introJs();
        intro.setOptions(options);
        intro.setOption('skipLabel', '跳过');
        intro.setOption('doneLabel', '完成');
        intro.setOption('nextLabel', '下一条');
        intro.setOption('prevLabel', '上一条');
        intro.oncomplete(function () {
            Cookies.set('show-' + type + '-intro', 1, { expires: 7 });
        });
        intro.start();
        intro.onexit(function () {
            Cookies.set('show-' + type + '-intro', 1, { expires: 3 });
        });
    }


    if (document.getElementById('repository-setting')) {
        if (Cookies.get('show-author-intro')!=='1') {
            startIntro(author, 'author');
        }
    } else {

        if (Cookies.get('show-visitor-intro')!=='1') {
            startIntro(visitor, 'visitor');
        }
    }


</script>